Introduction

The purpose of this notebook is to serve as a quick reference to a few clustering algorithms implemented in python and R.

Python implementations

from matplotlib import pyplot as plt
plt.style.use('seaborn-whitegrid')
import numpy as np
from sklearn.cluster import KMeans
np.random.seed(7)
points = np.vstack(((np.random.randn(150, 2) * 0.75 + np.array([1, 0])),
                   (np.random.randn(50, 2) * 0.25 + np.array([-0.5, 0.5])),
                   (np.random.randn(50, 2) * 0.5 + np.array([-0.5, -0.5]))))
from matplotlib import pyplot as plt
fig = plt.figure()
ax = plt.axes()
ax.scatter(points[:,0], points[:,1])
plt.show()